{extend name="common:frm_base" /}
{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">活动名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <select name="status">
                            <option value="all">请选择状态</option>
                            <option value="0">审核中</option>
                            <option value="1">审核通过</option>
                            <option value="2">审核不通过</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>
        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <button class="layui-btn layuiadmin-btn-useradmin" data-type="batchdel">删除</button>
                <button class="layui-btn layuiadmin-btn-useradmin" data-type="add">添加</button>
            </div>

            <table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>
            <script type="text/html" id="imgTpl">
                {{#  if(d.status == 1){ }}
                <img onclick="test('{{ d.code }}');" style="display: inline-block; width:34px;height:34px;" src="{{ d.code }}">
                {{# } }}
            </script>
            <script type="text/html" id="statusTpl">
                {{#  if(d.status == 1){ }}
                <span class="layui-btn layui-btn-xs layui-btn-normal">审核通过</span>
                {{#  } else if(d.status==2){ }}
                <span class="layui-btn layui-btn-xs layui-btn-danger">审核不通过</span>
                {{#  } else { }}
                <span class="layui-btn layui-btn-xs layui-btn-warm">审核中</span>
                {{#  } }}
            </script>
            <script type="text/html" id="table-useradmin-webuser">
                {{# if(d.report_contents){ }}
                    {{# if(d.is_end==1){}}
                        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="suc">已审批</a>
                    {{# }else if(d.is_end==2){}}
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="suc">审批不通过</a>
                    {{# }else{ }}
                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="suc">内容汇报</a>
                    {{# } }}
                {{#  }else{ }}
                <a class="layui-btn layui-btn-xs" lay-event="sub_info">上报内容</a>
                {{#  } }}
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="apply">报名列表</a>
                {{# if(d.status!=1){ }}
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                {{# }else{ }}
                {if !$_SESSION['xm_travel']['admin_info']['oid'] && !$_SESSION['xm_travel']['admin_info']['site_id']}
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                {else /}
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a>
                {/if}
                {{# } }}
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i
                       class="layui-icon layui-icon-delete"></i>删除</a>
            </script>
        </div>
    </div>
</div>

<script>


    layui.config({
        base: '__LAYUIADMIN__/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table;

        //监听搜索
        form.on('submit(LAY-user-front-search)', function (data) {
            var field = data.field;
            //执行重载
            table.reload('LAY-user-manage', {
                where: field
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
        //用户管理
        table.render({
            elem: '#LAY-user-manage'
            , url: "{:url('practice/ajaxIndex')}" //模拟接口
            , where:{ status:'{$status}' }
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'id', width: 100, title: 'ID', sort: true}
                , {field: 'title', title: '活动名称', minWidth: 100}
                , {field: 'activity_use_time', title: '开始时间', minWidth: 100}
                , {field: 'activity_end_time', title: '结束时间', minWidth: 100}
                // , {field: 'realname', title: '联系人', minWidth: 100}
                // , {field: 'mobile', title: '联系电话', minWidth: 100}
                // , {field: 'code', title: '二维码', minWidth: 100, toolbar:'#imgTpl'}
                , {field: 'status', title: '状态', toolbar:'#statusTpl'}
                // , {field: 'create_time', title: '添加时间', sort: true,}
                , {title: '操作', width: 350, align: 'center', fixed: 'right', toolbar: '#table-useradmin-webuser'}
            ]]
            , method: 'post'
            , page: true
            , limit: 30
            , height: 'full-180'
            , text: '对不起，加载出现异常！'
        });

        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
            var type = $(this).data('type');
            var url = "";
            if (type == 'add') {
                url = "{:url('practice/add')}";
            }
            active[type] ? active[type].call(this, url, table) : '';
        });
    });
    function test(img){
        var json= {
            "title": "", //相册标题
            "id": 123, //相册id
            "start": 0, //初始显示的图片序号，默认0
            "data": [ //相册包含的图片，数组格式
                {
                    "alt": "图片名",
                    "pid": 0, //图片id
                    "src": img, //原图地址
                    "thumb": "" //缩略图地址
                }
            ]
        }
        layer.photos({
            photos: json
            ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
        });
    }
</script>
</body>
</html>
{/block}
